Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: adding tests for jsobject regression tests #38214

Open
wants to merge 5 commits into
base: release
Choose a base branch
from

Conversation

NandanAnantharamu
Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu commented Dec 17, 2024

/ok-to-test tags="@tag.All"

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12441999066
Commit: ada8c84
Cypress dashboard.
Tags: @tag.All
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilTableWidgetSnapshot_spec.ts
  2. cypress/e2e/Regression/ClientSide/Binding/TableV2TextPagination_spec.js
  3. cypress/e2e/Regression/ClientSide/Github/EnableGithub_spec.ts
  4. cypress/e2e/Regression/ServerSide/QueryPane/AddWidgetTableAndBind_spec.js
List of identified flaky tests.
Sat, 21 Dec 2024 05:20:23 UTC

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive test suite for managing JavaScript objects, covering creation, deletion, and UI interactions.
    • Added a new test specification for forking applications, validating the process and user experience.
  • Bug Fixes

    • Enhanced testing to ensure JSObjects with identical names do not coexist.
  • Chores

    • Updated test specification paths to reflect new focus areas.
    • Modified visibility of a property to improve accessibility in tests and other application areas.
  • Refactor

    • Added new properties in the EntityExplorer, JSEditor, and CommonLocators classes to enhance functionality and UI management.

Copy link
Contributor

coderabbitai bot commented Dec 17, 2024

Walkthrough

This pull request introduces a comprehensive test suite for JavaScript Objects (JSObjects) in the Cypress testing framework. The changes include adding a new test specification file JSObject_Tests_spec.ts, updating the limited-tests.txt file, and extending the EntityExplorer, JSEditor, and CommonLocators classes with new properties to support enhanced testing capabilities. The modifications aim to improve test coverage for JSObject functionalities, including creation, deletion, moving, and binding operations.

Changes

File Change Summary
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts New end-to-end test suite for JSObject functionalities
app/client/cypress/limited-tests.txt Updated test specification path from template to JSObject tests; added new test specification path
app/client/cypress/support/Pages/EntityExplorer.ts Added _entityName selector property
app/client/cypress/support/Pages/JSEditor.ts Added _addJSObj, _jsPageActions, and _moreActions properties
app/client/cypress/support/Objects/CommonLocators.ts Added _editorTab selector property and _entityTestId method
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts New test case for forking an application
app/client/cypress/support/Pages/HomePage.ts Changed _forkModal visibility from private to public

Suggested labels

Bug, JS Objects

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

Poem

🧪 Cypress dances, JS Objects take flight,
Testing realms with code so bright!
From creation to binding, each test shines clear,
Ensuring quality without a fear!
Code poetry in motion, tests so divine! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=1

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Dec 17, 2024
Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1)

70-77: Remove commented-out test code.

Commented-out test code should either be implemented or removed to maintain code cleanliness.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35a5d83 and 76a8e2f.

📒 Files selected for processing (4)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
  • app/client/cypress/support/Pages/EntityExplorer.ts (1 hunks)
  • app/client/cypress/support/Pages/JSEditor.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/cypress/limited-tests.txt
🧰 Additional context used
📓 Path-based instructions (3)
app/client/cypress/support/Pages/EntityExplorer.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
app/client/cypress/support/Pages/JSEditor.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.

assertHelper.AssertNetworkStatus("@postExecute", 200);
agHelper.ClickButton("Got it");
assertHelper.AssertNetworkStatus("@updateLayout", 200);
agHelper.Sleep(2000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove explicit sleep calls.

Using agHelper.Sleep() violates the coding guidelines. Use Cypress's built-in retry-ability and assertions instead.

-    agHelper.Sleep(2000);
+    agHelper.AssertElementVisibility(table.locators._table);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
agHelper.Sleep(2000);
agHelper.AssertElementVisibility(table.locators._table);

PageLeftPane.switchSegment(PagePaneSegment.UI);
entityExplorer.DragDropWidgetNVerify(draggableWidgets.BUTTON, 500, 100);
propPane.EnterJSContext("onClick", "{{JSObject11.myFun1();}}", true, false);
agHelper.GetNClick(locators._widgetInDeployed("buttonwidget"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use data- attributes for selectors.*

Replace hardcoded widget selector with a data-* attribute as per coding guidelines.

-    agHelper.GetNClick(locators._widgetInDeployed("buttonwidget"));
+    agHelper.GetNClick("[data-testid='t--widget-buttonwidget']");

Committable suggestion skipped: line range outside the PR's diff.

@@ -72,6 +72,7 @@ export class EntityExplorer {
_widgetTagSuggestedWidgets = ".widget-tag-collapsible-suggested";
_widgetTagBuildingBlocks = ".widget-tag-collapsible-building-blocks";
_widgetSeeMoreButton = "[data-testid='t--explorer-ui-entity-tag-see-more']";
_entityName = ".t--entity-name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider reusing existing selector.

The selector .t--entity-name is already used in the code (e.g., in DeleteAllQueriesForDB method). To maintain DRY principles, consider reusing the existing selector reference.

-  _entityName = ".t--entity-name"

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +92 to +94
_addJSObj = '[data-testid="t--ide-tabs-add-button"]';
_jsPageActions = ".entity-context-menu";
_moreActions = '[data-testid="t--more-action-trigger"]';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove duplicate selector and follow consistent naming.

The _moreActions selector duplicates the existing contextMenuTriggerLocator property. Both use the same data-testid attribute.

    _addJSObj = '[data-testid="t--ide-tabs-add-button"]';
    _jsPageActions = ".entity-context-menu";
-    _moreActions = '[data-testid="t--more-action-trigger"]';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
_addJSObj = '[data-testid="t--ide-tabs-add-button"]';
_jsPageActions = ".entity-context-menu";
_moreActions = '[data-testid="t--more-action-trigger"]';
_addJSObj = '[data-testid="t--ide-tabs-add-button"]';
_jsPageActions = ".entity-context-menu";

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12379191533.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 9 Total Passed: 9 Total Failed: 0 Total Skipped: 0 *****************************

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=15

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12386012942.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 135 Total Passed: 135 Total Failed: 0 Total Skipped: 0 *****************************

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=1

Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76a8e2f and f02d097.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1 hunks)
  • app/client/cypress/support/Objects/CommonLocators.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/support/Objects/CommonLocators.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.

@@ -346,4 +346,5 @@ export class CommonLocators {
_showBoundary = ".show-boundary";
_entityItem = "[data-testid='t--entity-item-Api1']";
_rowData = "[data-colindex='0'][data-rowindex='0']";
_editorTab = ".editor-tab";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use data-testid attribute instead of CSS class selector

According to the coding guidelines, we should use data-* attributes for selectors instead of CSS class selectors.

Replace the CSS class selector with a data-testid attribute:

-  _editorTab = ".editor-tab";
+  _editorTab = "[data-testid='t--editor-tab']";

This change requires updating the corresponding HTML element to include the data-testid attribute:

<div data-testid="t--editor-tab">...</div>

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12405640526.
Cypress dashboard url: Click here!
All Cypress tests have passed 🎉🎉🎉

***** Repeat Run Summary ***** Total Tests with repeat: 10 Total Passed: 9 Total Failed: 1 Total Skipped: 0 *****************************

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=10

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (2)

21-22: Empty before() hook should be removed or utilized

The empty before() hook serves no purpose and should either be removed or implemented with necessary test setup.

-  before(() => {});

70-86: Remove commented test code

The commented code for "Copy to Page" and "Rename" verification should either be implemented or removed. Keeping commented code adds unnecessary complexity and maintenance overhead.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f02d097 and efc61ae.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
🔇 Additional comments (3)
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (3)

272-273: Remove explicit sleep calls

Using agHelper.Sleep() violates the coding guidelines. Use Cypress's built-in retry-ability and assertions instead.

-    agHelper.Sleep(2000);
+    agHelper.AssertElementVisibility(table.locators._table);

122-122: Use data- attributes for selectors*

Replace hardcoded widget selector with a data-* attribute as per coding guidelines.

-    agHelper.GetNClick(locators._widgetInDeployed("buttonwidget"));
+    agHelper.GetNClick("[data-testid='t--widget-buttonwidget']");

286-309: Add timeline for addressing skipped tests

The skipped tests reference bugs #35385 and #38216, but there's no indication of when these will be addressed. Consider:

  1. Adding TODO comments with expected timeline
  2. Creating GitHub issues if not already existing
  3. Adding acceptance criteria for when these tests can be unskipped
✅ Verification successful

Both skipped tests are tracking active issues that need resolution

Both referenced issues are still open:

The skipped tests are correctly tracking real issues, with proper bug references and assigned owners. No timeline comments needed as these are being actively worked on.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the referenced issues are still open
gh issue view 35385
gh issue view 38216

Length of output: 2034

Copy link

@NandanAnantharamu NandanAnantharamu added the ok-to-test Required label for CI label Dec 19, 2024
Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12417485057.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 100 Total Passed: 80 Total Failed: 0 Total Skipped: 0 *****************************

agHelper.GetNClickByContains(HomePage.portalMenuItem, "Are you sure?");
agHelper.ValidateToastMessage("JSObject4 deleted successfully");

// Verify Copy to Page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give bug link.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
app/client/cypress/support/Pages/HomePage.ts (2)

92-92: Consider keeping _forkModal private and providing a public accessor method instead.

The underscore prefix naming convention suggests this should be a private member. Consider keeping it private and adding a public getter method like getForkModalSelector() to maintain encapsulation while allowing external access.

-  public _forkModal = ".fork-modal";
+  private _forkModal = ".fork-modal";
+  public getForkModalSelector() {
+    return this._forkModal;
+  }

Line range hint 32-38: Consider using data-testid for fork modal selector.

Replace the class selector with a data-testid attribute for better test maintainability and resilience to styling changes.

-  public _forkModal = ".fork-modal";
+  public _forkModal = "[data-testid=t--fork-modal]";
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts (2)

9-10: Remove unnecessary empty options object

The empty options object in the describe function can be removed.

-describe("Fork application", {}, function () {
+describe("Fork application", function () {

10-25: Add more assertions for robust testing

The test would benefit from additional assertions to verify the fork operation more thoroughly:

  1. Verify the new application's workspace
  2. Verify the application's content after forking

Consider adding these assertions after navigation:

// Verify workspace
cy.get('[data-testid="t--workspace-name"]').should('be.visible');

// Verify application content
cy.get('[data-testid="t--application-content"]')
  .should('exist')
  .and('contain', 'JS object testing');
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efc61ae and 3593a14.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts (1 hunks)
  • app/client/cypress/support/Pages/HomePage.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/client/cypress/support/Pages/HomePage.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
🔇 Additional comments (1)
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts (1)

1-8: LGTM! Clean imports structure

The imports are well-organized and follow good practices.

it("1. Fork app and verify", () => {
homePage.ImportApp("jsObjectTesting.json");
agHelper.GetNClick(homePage._applicationName);
agHelper.GetNClickByContains;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove incomplete statement

This line appears to be an incomplete function call and serves no purpose.

-    agHelper.GetNClickByContains;

);
agHelper.GetNClick(locators._forkAppToWorkspaceBtn);
assertHelper.AssertNetworkStatus("@postForkAppWorkspace", 200);
agHelper.WaitUntilEleDisappear(homePage._forkModal);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace wait with better assertion

According to the guidelines, we should avoid using wait functions. Instead, use Cypress's built-in retry-ability with assertions.

-    agHelper.WaitUntilEleDisappear(homePage._forkModal);
+    cy.get(homePage._forkModal).should('not.exist');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
agHelper.WaitUntilEleDisappear(homePage._forkModal);
cy.get(homePage._forkModal).should('not.exist');

Comment on lines +22 to +24
agHelper.AssertElementExist(
`${homePage._applicationCard}:contains('JS object testing upto 1.5 MB (1)')`,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use data- attributes for selectors*

Avoid using string selectors in assertions. Instead, use data-* attributes for more reliable element selection.

-    agHelper.AssertElementExist(
-      `${homePage._applicationCard}:contains('JS object testing upto 1.5 MB (1)')`,
-    );
+    cy.get('[data-testid="t--application-card"]')
+      .should('exist')
+      .and('contain', 'JS object testing upto 1.5 MB (1)');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
agHelper.AssertElementExist(
`${homePage._applicationCard}:contains('JS object testing upto 1.5 MB (1)')`,
);
cy.get('[data-testid="t--application-card"]')
.should('exist')
.and('contain', 'JS object testing upto 1.5 MB (1)');

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (3)
app/client/cypress/support/Objects/CommonLocators.ts (1)

349-349: ⚠️ Potential issue

Use data-testid attribute instead of CSS class selector

The selector uses a CSS class which violates the coding guidelines for Cypress tests.

Replace the CSS class selector with a data-testid attribute:

-  _editorTab = ".editor-tab";
+  _editorTab = "[data-testid='t--editor-tab']";
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts (2)

19-19: ⚠️ Potential issue

Remove incomplete statement

This line appears to be an incomplete function call and serves no purpose.

-    agHelper.GetNClickByContains;

27-27: 🛠️ Refactor suggestion

Replace wait with better assertion

According to the guidelines, we should avoid using wait functions. Instead, use Cypress's built-in retry-ability with assertions.

-    agHelper.WaitUntilEleDisappear(homePage._forkModal);
+    cy.get(homePage._forkModal).should('not.exist');
🧹 Nitpick comments (1)
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts (1)

45-51: Add assertions for JSObject creation

The JSObject creation lacks proper assertions to verify the success of the operation.

     jsEditor.CreateJSObject('"MiddleName": "Test",\n', {
       paste: false,
       toRun: false,
       completeReplace: false,
       shouldCreateNewJSObj: false,
       lineNumber: 5,
-    });
+    });
+    cy.get('.t--js-editor').should('be.visible');
+    cy.get('.t--js-editor').should('contain', 'MiddleName');
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3593a14 and ada8c84.

📒 Files selected for processing (3)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts (1 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
  • app/client/cypress/support/Objects/CommonLocators.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/limited-tests.txt
🧰 Additional context used
📓 Path-based instructions (2)
app/client/cypress/support/Objects/CommonLocators.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
🔇 Additional comments (2)
app/client/cypress/support/Objects/CommonLocators.ts (1)

350-351: LGTM! Well-structured selector using data-testid

The method follows best practices by using data-testid attribute for element selection.

app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts (1)

1-14: LGTM! Clean imports structure

The imports are well-organized and properly destructured.

agHelper.AssertClassExists(locators._entityTestId("J16"), "active");
agHelper.GetNClick(locators._entityTestId("J17"));
agHelper.AssertClassExists(locators._entityTestId("J17"), "active");
agHelper.GetNAssertContains(".CodeMirror-line ", '"MiddleName": "Test"');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use data-testid for CodeMirror assertions

Avoid using class selectors for assertions. Instead, use data-testid attributes.

-    agHelper.GetNAssertContains(".CodeMirror-line ", '"MiddleName": "Test"');
+    cy.get('[data-testid="code-editor-line"]').should('contain', '"MiddleName": "Test"');

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +34 to +43
for (let i = 1; i <= 11; i++) {
agHelper.GetNClick(locators._entityTestId(`JS${i}`));
agHelper.FailIfErrorToast("");
agHelper.AssertClassExists(locators._entityTestId(`JS${i}`), "active");
}
for (let i = 12; i <= 17; i++) {
agHelper.GetNClick(locators._entityTestId(`J${i}`));
agHelper.FailIfErrorToast("");
agHelper.AssertClassExists(locators._entityTestId(`J${i}`), "active");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor duplicate loops

The two loops have similar logic and can be combined to reduce code duplication.

-    for (let i = 1; i <= 11; i++) {
-      agHelper.GetNClick(locators._entityTestId(`JS${i}`));
-      agHelper.FailIfErrorToast("");
-      agHelper.AssertClassExists(locators._entityTestId(`JS${i}`), "active");
-    }
-    for (let i = 12; i <= 17; i++) {
-      agHelper.GetNClick(locators._entityTestId(`J${i}`));
-      agHelper.FailIfErrorToast("");
-      agHelper.AssertClassExists(locators._entityTestId(`J${i}`), "active");
-    }
+    const entityIds = [
+      ...Array.from({ length: 11 }, (_, i) => `JS${i + 1}`),
+      ...Array.from({ length: 6 }, (_, i) => `J${i + 12}`)
+    ];
+    entityIds.forEach(id => {
+      cy.get(locators._entityTestId(id))
+        .click()
+        .should('have.class', 'active');
+      agHelper.FailIfErrorToast("");
+    });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for (let i = 1; i <= 11; i++) {
agHelper.GetNClick(locators._entityTestId(`JS${i}`));
agHelper.FailIfErrorToast("");
agHelper.AssertClassExists(locators._entityTestId(`JS${i}`), "active");
}
for (let i = 12; i <= 17; i++) {
agHelper.GetNClick(locators._entityTestId(`J${i}`));
agHelper.FailIfErrorToast("");
agHelper.AssertClassExists(locators._entityTestId(`J${i}`), "active");
}
const entityIds = [
...Array.from({ length: 11 }, (_, i) => `JS${i + 1}`),
...Array.from({ length: 6 }, (_, i) => `J${i + 12}`)
];
entityIds.forEach(id => {
cy.get(locators._entityTestId(id))
.click()
.should('have.class', 'active');
agHelper.FailIfErrorToast("");
});

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=1

Copy link

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=1

Copy link

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=1 update_snapshot=false specs_to_run=cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts,
cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts

Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/12460935225.
Cypress dashboard
PR: #38214 with spec: cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts, .

@sagar-qa007
Copy link
Contributor

/ci-test-limit-count run_count=1 update_snapshot=true specs_to_run=cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts,
cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts runId=12460935225

Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/12461387912.
Cypress dashboard
PR: #38214 with spec: cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts, .

@sagar-qa007
Copy link
Contributor

/ci-test-limit-count run_count=1 update_snapshot=true specs_to_run=cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts,cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts runId=12460935225

Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/12461402029.
Cypress dashboard
PR: #38214 with spec: cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts,cypress/e2e/Regression/ClientSide/JSObject/JSObject_ForkApp_spec.ts .

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12461402029.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 11 Total Passed: 9 Total Failed: 0 Total Skipped: 0 *****************************

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants